<?php

namespace App\Http\Controllers\Dashboard;

use App\Http\Controllers\Controller;
use App\Http\Resources\Dashboard\WorkResource;
use App\Models\Course;
use App\Models\Work;
use Illuminate\Http\Request;

class WorkController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @param Course $course
     * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
     */
    public function index(Course $course)
    {
        return WorkResource::collection($course->works);
    }


    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @param Course $course
     * @return void
     */
    public function store(Request $request,Course $course)
    {
        $course->works()->create($request->only(['question','data','type']));
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Models\Work $work
     * @return WorkResource
     */
    public function show(Work $work)
    {
        return new WorkResource($work);
    }


    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Work  $work
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, Work $work)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Models\Work  $work
     * @return \Illuminate\Http\Response
     */
    public function destroy(Work $work)
    {
        //
    }
}
